﻿<!DOCTYPE html>
<html ng-app="demoApp">
<head>
    <title id="Description">jqxDropDownList directive for AngularJS</title>
    <meta name="description" content="AngularJS DropDownList example. This example demonstrates a DropDownList directive." /> 
    <link rel="stylesheet" type="text/css" href="../../../jqwidgets/styles/jqx.base.css" />
    <script type="text/javascript" src="../../../scripts/angular.min.js"></script>
    <script type="text/javascript" src="../../../scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxlistbox.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxdropdownlist.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxangular.js"></script>
    <script type="text/javascript" src="../../../scripts/demos.js"></script>
    <script type="text/javascript">
        var demoApp = angular.module("demoApp", ["jqwidgets"]);
        demoApp.controller("demoController", function ($scope) {
            $scope.people = [{
                id: 1,
                name: "Pedro",
                age: 13
            }, {
                id: 2,
                name: "Clara",
                age: 22
            }, {
                id: 3,
                name: "John",
                age: 33
            }, {
                id: 4,
                name: "Pier",
                age: 27
            }];

            // init DropDownList's settings object.
            $scope.dropDownListSettings =
            {
                width: 200,
                height: 30,
                autoDropDownHeight: true,
                displayMember: "name",
                valueMember: "id",
                source: $scope.people
            }

            // init selectedValue.
            $scope.selectedValue = $scope.people[0];

            // change the data source.
            $scope.changeSource = function () {
                $scope.dropDownListSettings.source = [{
                    id: 1,
                    name: "Nancy",
                    age: 18
                }, {
                    id: 2,
                    name: "Andrew",
                    age: 22
                }, {
                    id: 3,
                    name: "Michael",
                    age: 56
                }, {
                    id: 4,
                    name: "Peter",
                    age: 23
                }];
            }
        });
    </script>
</head>
<body>
    <div ng-controller="demoController">
         <p><b>Label: </b>{{selectedValue.name}}, <b>Value: </b>{{selectedValue.id}}</p>
        <jqx-drop-down-list ng-model="selectedValue" jqx-ng-model jqx-settings="dropDownListSettings"></jqx-drop-down-list>
        <br />
        <jqx-button ng-click="changeSource()">Change Source</jqx-button>
    </div>
</body>
</html>
